package com.xm.servlet.background.orders;

import com.google.gson.Gson;
import com.xm.entity.LogisticsStation;
import com.xm.service.background.LogisticsStationService;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 新增物流站
 * @author 康文程
 * @date 2024-1-13
 */
@WebServlet("/background/new/logistics/station")
public class NewLogisticsStationServlet extends HttpServlet {
    private final LogisticsStationService service = new LogisticsStationService();
    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String logisticsStationJson = req.getParameter("logisticsStationJson");
        LogisticsStation logisticsStation = new Gson().fromJson(logisticsStationJson, LogisticsStation.class);
        System.out.println(logisticsStation);
        service.addLogisticsStation(logisticsStation);
    }
}
